package com.xxx.service;

import com.xxx.dao.StudentDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/8/16 15:05
 * @Copyright 博为峰
 */
//@Component(value = "studentService")
@Service(value = "studentService")
//@Scope("prototype")
@Lazy(value = true)
public class StudentServiceImpl implements StudentService {

//    @Autowired
//    @Qualifier("studentDao02")
    @Resource(name = "studentDao02")
    public StudentDao studentDao;

    public void setStudentDao(StudentDao studentDao) {
        this.studentDao = studentDao;
    }

    public StudentServiceImpl() {
        System.out.println("StudentServiceImpl");
    }

    @Override
    public int addStudent() {
        return studentDao.insertStudent();
    }

    @PostConstruct
    public void init() {
        System.out.println("init...");
    }

    @PreDestroy
    public void destroy() {
        System.out.println("destroy");
    }
}
